#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 10;
int a[N], b[N];
int n;

bool check(int k) {
    int l = -k, r = k;
    for(int i = 0; i < n; i++){
        // cout << l << ' ' << r << endl;
        if(l > b[i] || r < a[i]) return false;
        l = max(l, a[i]) - k;
        r = min(r, b[i]) + k;
    }
    return true;
}

void solve() {
    cin >> n;
    for(int i = 0; i < n; i++) {
        cin >> a[i] >> b[i];
    }
    int l = 0, r = 1e9;
    while(l < r) {
        int mid = l + r >> 1;
        // cout << mid << endl;
        if(check(mid)) r = mid;
        else l = mid + 1;
    }
    cout << l << '\n';
}

int main() {
    int t;
    cin >> t;
    while(t--) solve();
    return 0;
}